<?php


/**
* Puree CMS
* http://www.molotsoft.ru
*
* @package Puree_CMS
* @subpackage Components
* @author Ivan Chistyakov <ivan@molotsoft.ru>
* @version $Id: captcha.php 1081 2010-03-24 09:27:49Z molotsoft@gmail.com $
* @link $HeadURL: http://puree-cms.googlecode.com/svn/trunk/controllers/components/captcha.php $
*/


class CaptchaComponent extends Object {

/******************************************************************************/

var $components = array(
	'Session'
);

/******************************************************************************/

function write($value) {
	return $this->Session->write('Captcha.value', $value);
}

function draw() {
	$this->drawKCAPTCHA(); // wrap
}

function drawKCAPTCHA() {
	App::import('Vendor', 'KCAPTCHA', array('file' => 'kcaptcha' . DS . 'kcaptcha.php'));
	$kcaptcha = new KCAPTCHA();
	$this->write($kcaptcha->getKeyString());
}

function check() {
	return $this->Session->check('Captcha.value');
}

function read() {
	return $this->Session->read('Captcha.value');
}

function match($value) {
	return $this->check() && ($value == $this->read());
}

function del() {
	return $this->Session->del('Captcha.value');
}

function delete() {
	return $this->del();
}

/******************************************************************************/

}


?>